package trading.ctm.yunjing.module.message.adapter

import android.view.View
import android.widget.TextView
import cc.vv.baselibrary.view.LKCircleImageView
import cc.vv.lkbasecomponent.base.ui.adapter.LKBaseSingleAdapter
import cc.vv.lkbasecomponent.base.ui.adapter.viewholder.LKBaseViewHolder
import trading.ctm.yunjing.R

class MessageAdapter : LKBaseSingleAdapter<String, LKBaseViewHolder> {

    constructor(resId: Int, data: List<String>) : super(resId, data) {

    }

    override fun convert(helper: LKBaseViewHolder?, item: String?) {
        super.convert(helper, item)

        if (null == helper) {
            return
        }

        var title = ""
        val civ_message_inform_icon = helper.getView<LKCircleImageView>(R.id.civ_message_inform_icon)
        when {
            0 == helper.adapterPosition -> {
                title = "供应消息"
                civ_message_inform_icon.setImageResource(R.mipmap.icon_supply_message)
            }
            1 == helper.adapterPosition -> {
                title = "拍卖消息"
                civ_message_inform_icon.setImageResource(R.mipmap.icon_auction_message)
            }
            2 == helper.adapterPosition -> {
                title = "系统消息"
                civ_message_inform_icon.setImageResource(R.mipmap.icon_system_message)
            }
        }

        helper.getView<TextView>(R.id.tv_message_title).text = title
        helper.getView<TextView>(R.id.tv_message_desc).text = item
        if (itemCount - 1 == helper.adapterPosition) {
            helper.getView<View>(R.id.view_message_line).visibility = View.GONE
        } else {
            helper.getView<View>(R.id.view_message_line).visibility = View.VISIBLE
        }
    }
}
